package com.gxar.file.server.db.respository;

import com.gxar.file.server.db.model.FileEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

/**
 * 素材DB层
 *
 * @author Linsy
 * @version 1.0
 * @created 2023/7/8
 **/
@Repository
public interface FileRepository extends JpaRepository<FileEntity, Long> {

    /**
     * 根据用户id和名称查询文件
     *
     * @param userId      用户id
     * @param name        名称
     * @param productName 产品名称
     * @return 文件
     */
    @Query(value = "select * from file where user_id = :#{#userId} and name = :#{#name} and product_name = :#{#productName}", nativeQuery = true)
    FileEntity findByUserIdAndName(@Param("userId") Long userId, @Param("name") String name, @Param("productName") String productName);
}